﻿@{
    Layout = null;
}

<div class="col-3 pr-0" style="display: none">
    <label id="SelectMaterial-ReturnLabId">@ViewData["ReturnLabId"]</label>
    <label id="SelectMaterial-MaterialName">@ViewData["MaterialName"]</label> // 这个值是当编辑已存在的物料时，默认显示的物料名称
</div>
<div class="input-group">
    <div class="col-3 pr-0">
        <span class="input-group-text font-rfs border-radius-noright noRightBorder">物料一级</span>
    </div>
    <div class="col-9 pl-0 input-group">
        <select id="SelectMaterial-Select-Type1" class="form-control font-rfs border-radius-noleft" style="width:90%"></select>
    </div>
</div>
<div class="input-group">
    <div class="col-3 pr-0">
        <span class="input-group-text font-rfs border-radius-noright noRightBorder">物料二级</span>
    </div>
    <div class="col-9 pl-0 input-group">
        <select id="SelectMaterial-Select-Type2" class="form-control font-rfs border-radius-noleft" style="width:90%"></select>
    </div>
</div>
<div class="input-group">
    <div class="col-3 pr-0">
        <span class="input-group-text font-rfs border-radius-noright noRightBorder">物料名称</span>
    </div>
    <div class="col-9 pl-0 input-group">
        <select id="SelectMaterial-Select-Name" class="form-control font-rfs border-radius-noleft" style="width:40%"></select>
    </div>
</div>

<script>

    $(document).ready(function () {
        LoadMaterialType1('SelectMaterial-Select-Type1');
        if ($("#SelectMaterial-MaterialName").html().length > 0) {
            $("#SelectMaterial-Select-Name").append(new Option($("#SelectMaterial-MaterialName").html()));
        }
    });

    $("#SelectMaterial-Select-Type1").change(function () {
        LoadMaterialType2('SelectMaterial-Select-Type2', $("#SelectMaterial-Select-Type1").find("option:selected").text(),);
    });

    $("#SelectMaterial-Select-Type2").change(function () {
        LoadMaterialCodeAndName('SelectMaterial-Select-Name', $("#SelectMaterial-Select-Type1").find("option:selected").text(), $("#SelectMaterial-Select-Type2").find("option:selected").text());
    });

    $("#SelectMaterial-Select-Name").change(function () {
        var name = $("#SelectMaterial-Select-Name").find("option:selected").text();
        var code = $("#SelectMaterial-Select-Name").find("option:selected").val();

        var LabId = $("#SelectMaterial-ReturnLabId").html();
        $("#" + LabId).attr('data-code', code);
        $("#" + LabId).attr('data-name', name);
    });

</script>
